#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>

int main() {
    std::string token = "479124711752132b3986ad12d9d157bb";
    std::vector<std::string> missing_repos = {
        "Catch", "zlib", "libpng", "libexpat", "libtiff",
        "libjpeg-turbo", "pcre", "nanosvg", "scintilla", 
        "lexilla", "libwebp"
    };

    std::cout << "🚀 开始批量创建缺失的镜像仓库..." << std::endl;
    std::cout << "📦 需要创建 " << missing_repos.size() << " 个仓库" << std::endl;
    
    int success_count = 0;
    
    for (const auto& repo : missing_repos) {
        std::cout << "创建: " << repo << " ... ";
        std::cout.flush();
        
        // 创建仓库
        std::string create_cmd = "curl -X POST \"https://gitee.com/api/v5/user/repos?access_token=" + token + "\" "
                               "-H \"Content-Type: application/json\" "
                               "-d \"{\\\"name\\\":\\\"" + repo + "\\\",\\\"description\\\":\\\"Mirror of https://github.com/wxWidgets/" + repo + ".git\\\",\\\"public\\\":true}\"";
        
        int result = system(create_cmd.c_str());
        
        if (result == 0) {
            std::cout << "✅ 成功" << std::endl;
            success_count++;
            
            // 等待一下，避免 API 限制
            system("timeout 1 > nul 2>&1");
        } else {
            std::cout << "❌ 失败" << std::endl;
        }
    }
    
    std::cout << "\n📊 创建结果:" << std::endl;
    std::cout << "✅ 成功创建: " << success_count << " 个" << std::endl;
    std::cout << "❌ 失败: " << (missing_repos.size() - success_count) << " 个" << std::endl;
    
    if (success_count > 0) {
        std::cout << "\n🎯 接下来运行:" << std::endl;
        std::cout << "cd /d/vc/wxWidgets" << std::endl;
        std::cout << "sed -i 's|https://github.com/wxWidgets/|https://gitee.com/uesoft/|g' .gitmodules" << std::endl;
        std::cout << "\"C:/Program Files/Git/bin/git.exe\" submodule sync" << std::endl;
        std::cout << "\"C:/Program Files/Git/bin/git.exe\" submodule update --init --recursive" << std::endl;
    }
    
    return 0;
}
